CONTENTS | INDEX | PREV | NEXT
 strspn

   NAME
    strspn  - scan a string until a character is found that does NOT match
          some character in a second string.

   SYNOPSIS
    int len = strspn(s, toks)
    const char *s;
    const char *toks;

   FUNCTION
    The string s is scanned until a character is found that does NOT
    match any character in the string toks.  The number of characters
    skipped is returned.  If every character in s matches some
    character in toks then the length of the string s is returned.

    This function is normally used to skip whitespace within a string.

   EXAMPLE
    #include <stdio.h>
    #include <string.h>
    #include <assert.h>

    main()
    {
        int len;

        len = strspn("  t tt abcde test", " t ");
        assert(len == 7);               /*  stopped at the 'a'  */

        len = strspn("abcd ", " ");
        assert(len == 0);

        len = strspn("   tt ", " t");
        assert(len == 6);               /*  all match, len = strlen(str);   */

        return(0);
    }

   INPUTS
    char *s;    pointer to string to scan
    char *toks; pointer to string containing characters to compare against

   RESULTS
    int len;  # of characters skipped in s before a match could not be found

   SEE ALSO
    strpbrk, strcspn